package com.itheima;

import com.itheima.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author: dh
 * @date: 2023-10-21 15:40
 * bean基础配置的运行类.
 */
public class AppForBean {

    public static void main(String[] args) {

        // 1.获得IoC容器.
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        // 2.通过getBean方法来获得bean对象.
        // BookService bookService = (BookService) ctx.getBean("bookService");
        // 2.1 使用"service"指定.
//        BookService bookService = (BookService) ctx.getBean("service");
        // 2.2 使用“bookService2"指定.
        BookService bookService = (BookService) ctx.getBean("bookService2");
        // 3.调用对象的方法.
        bookService.save();
    }
}
